<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<!--{include file='comm/header.tpl'}-->
    <title>角色列表</title>
</head>
<body>

<!--{include file='comm/naviBanner.tpl'}-->

<div class="container">

    <!--{include file='comm/menu.tpl'}-->

        <div class="comm_crub">
            <span class="now_crub">角色列表</span>
        </div>

        <div class="comm_content">

            <div  class="search-box">
                <div style="position:relative">
                    <form id="searchForm">
                        <table>
                            <tr>
                                <td>
                                    <span>
                                        角色组 ：<select id="roleGroupID" name="roleGroupID" >
                                            <option value="">请选择</option>
                                            <!--{foreach from=$role_group_array item=role_group}-->
                                            <option value="<!--{$role_group.roleGroupID}-->"><!--{$role_group.roleGroupName}--></option>
                                            <!--{/foreach}-->
                                        </select>
                                    </span>
                                    <span><input type="button" class="btn" value="查询" onclick="role.search();"></span>
                                    <span><input type="reset" class="btn" value="重置"></span>
                                </td>
                            </tr>
                        </table>
                    </form>
                </div>
            </div>

            <table id="flex" style="display:none"></table>

        </div>

   

</div>

	<script type="text/javascript">
		$("#flex").flexigrid({
			url:"/invokingAjax-backend/user/roleList.ajax?operFlg=1&xjx=none",
	        dataType: "json",
	        colModel : [
                <!--{if $edit_permission}-->
				{display: "操作", width : 150, align: 'center'},
                <!--{/if}-->
				{display: "角色ID", name : "roleID" , width : 100 , sortable : true },
	            {display: "角色名称", width : 150},
				{display: "角色组名称", width : 150},
				{display: "备注", width : 150},
	        ],
            <!--{if $edit_permission}-->
	        buttons : [
	            {name: "添加", bclass: "add", onpress : "role.edit"},
	            {separator: true},
	            {name: "删除", bclass: "delete", onpress : "role.del.check"}
	        ],
            <!--{/if}-->
	        sortname: "roleID",
	        sortorder: "DESC",
	        usepager: true,
	        rp: 10,
	        useRp: true,
	        showTableToggleBtn: true
		});


		var role = {

			search: function() {
	            var dt = $('#searchForm').serializeArray();
	            $("#flex").flexOptions({newp: 1, params: dt}).flexReload();
	        },

			edit: function( roleID ) {
                if (roleID) {
                    E.open("/quanliadmin/app/user/roleList.pscript?operFlg=2&roleID=" + roleID);
                } else {
                    E.open("/quanliadmin/app/user/roleList.pscript?operFlg=2");
                }
			},

            del: {

                r_array: "",

                check: function(){

                    //获取选中的行的行数
                    var selected_count=$('.trSelected',flex).length;
                    if (selected_count==0) {
                        E.alert('请选择要删除的角色');
                    } else {
                        this.r_array = new Array();
                        for(var i=0; i<selected_count; i++){
                            var typeIDStr = $('.trSelected',flex).eq(i).attr('id');
                            this.r_array.push(typeIDStr.substr(3));
                        }

                        //弹出确认层
                        E.confirm("您确认要删除已选择的角色吗？", "role.del.execute");

                    }
                },

                execute: function() {

                    E.ajax_get({
                        url: "/invokingAjax-backend/user/roleList.ajax?operFlg=3",
                        data:{
                            r_array: this.r_array
                        },
                        call: "role.load"
                    });

                }

            },

			permission: function( roleID ){
				E.open("/quanliadmin/app/user/roleList.pscript?operFlg=3&roleID=" + roleID , "", {height: 600,width: 1024, top: 50, left: 150});
			},

			load: function() {
				$("#flex").flexReload();
			}

		};
	</script>
</body>
</html>